
import Vue from 'vue'
import VueRouter from 'vue-router'
import recommend from '../views/recommend.vue'

Vue.use(VueRouter)

const routes = [
  {
    path:"/",
    redirect:"recommend"
  },
  {
    path:"/recommend",
    name:'recommend',
    component:recommend
  },
  {
    path:"/singer",
    name:"singer",
    component:()=>import("../views/singer.vue")
  },
  {
    path:"/rank",
    name:"rank",
    component:()=>import("../views/rank.vue")
  },
  {
    path:"/rankItem",
    name:"rankItem",
    component:()=>import("../components/rankItem.vue")
  },
  {
    path:"/myHome",
    name:"myHome",
    component:()=>import("../components/myHome.vue")
  },
  {
    path:"/search",
    name:"search",
    component:()=>import("../components/Search.vue")
  },
  {
    path:"/userInfo",
    name:"userInfo",
    component:()=>import("../views/userinfo.vue"),
    beforeEnter:(to,from,next)=>{
      let login = window.localStorage.getItem("token");
      // 判断没有值
      if(!login){
        next("/login");
        return;
      }else{
        next();
      }
    }
  },
  {
    path:"/login",
    name:"login",
    component:()=>import("../components/login.vue"),
  },
  {
    path:"/daySong",
    name:"daySong",
    component:()=>import("../components/daySong.vue"),
  },
  {
    path:"/srFM",
    name:"srFM",
    component:()=>import("../components/srFM.vue"),
  },
  {
    path:"/mv",
    name:"mv",
    component:()=>import("../components/mv.vue"),
   
  },
  {
    path:"/searchData",
    name:"searchData",
    component:()=>import("../components/searchData.vue"),
  },
  {
    path:"/songGerItem",
    name:"songGerItem",
    component:()=>import("../components/songGerItem.vue"),
  },
  {
    path:"/comment",
    name:"comment",
    component:()=>import("../components/comment.vue"),
  },
  {
    path:"/album",
    name:"album",
    component:()=>import("../components/album.vue"),
  },
  {
    path:"/gz",
    name:"gz",
    component:()=>import("../components/gz.vue"),
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
